// keyName:侧边栏或者头部过滤路由的字符串标识
// dataBob:是否需要提取对应路径下的数据
// path:提取数据的路径
// 全部路由数据
export const routes = (keyName = "", dataBob = false, path = "") => {
  const routeArr = [
    { text: "首页", link: "/", keyName: "nav" },
    {
      text: "简介",
      link: "/pages/start/briefIntroduction",
      keyName: "起步,nav",
    },
    {
      text: "内置样式",
      link: "/pages/start/scss",
      keyName: "起步",
    },
    {
      text: "快速开始",
      link: "/pages/start/quickStart",
      keyName: "起步,nav",
    },
    {
      text: "工具函数",
      link: "/pages/toolLibrary/util",
      keyName: "工具库,nav",
    },
    {
      text: "低功耗蓝牙",
      link: "/pages/toolLibrary/ble",
      keyName: "工具库",
    },
    {
      text: "app权限判断",
      link: "/pages/toolLibrary/permission",
      keyName: "工具库",
    },
    {
      text: "crypto加密文件",
      link: "/pages/toolLibrary/crypto",
      keyName: "工具库",
    },
    {
      text: "oss前端上传",
      link: "/pages/toolLibrary/uploadOss",
      keyName: "工具库",
    },
    {
      text: "拦截器",
      link: "/pages/api/request",
      keyName: "网络请求",
    },
    {
      text: "请求配置",
      link: "/pages/api/common",
      keyName: "网络请求",
    },
    {
      text: "组件首页",
      link: "/pages/componentDocumentation/componentsIndex",
      keyName: "组件文档,nav",
      urlKey: "",
    },
    {
      text: "支付控件",
      link: "/pages/componentDocumentation/uniBytPay",
      keyName: "组件文档",
      urlKey: "uniBytPayPage",
    },
    {
      text: "自定义头部",
      link: "/pages/componentDocumentation/uniBytTopCom",
      keyName: "组件文档",
      urlKey: "uniBytTopComPage",
    },
    {
      text: "支付密码弹窗",
      link: "/pages/componentDocumentation/uniBytPasswordInput",
      keyName: "组件文档",
      urlKey: "uniBytPasswordInput",
    },
    {
      text: "多选树形组件",
      link: "/pages/componentDocumentation/uniBytCheckboxTree",
      keyName: "组件文档",
      urlKey: "uniBytCheckboxTree",
    },
    {
      text: "时间区间选择",
      link: "/pages/componentDocumentation/uniBytDateRang",
      keyName: "组件文档",
      urlKey: "uniBytDateRang",
    },
  ];
  if (dataBob) {
    return routeArr.find((item) => item.link.includes(path));
  } else {
    return routeArr.filter((item) => item.keyName.includes(keyName));
  }
};

// 头部导航栏数据
export const navRoutes = () => {
  return routes("nav");
};

// 内容主题侧边栏数据
export const sidebarRoutes = () => {
  return [
    {
      text: "起步",
      items: routes("起步"),
    },
    {
      text: "组件文档",
      items: routes("组件文档"),
    },
    {
      text: "网络请求",
      items: routes("网络请求"),
    },
    {
      text: "工具库",
      items: routes("工具库"),
    },
  ];
};
